package com.hanhanxiaochong.zhongxiangchuanmei.view.home.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.hanhanxiaochong.zhongxiangchuanmei.R;
import com.hanhanxiaochong.zhongxiangchuanmei.bean.VipProjectItem;
import com.hanhanxiaochong.zhongxiangchuanmei.config.CommonAdapter;
import com.hanhanxiaochong.zhongxiangchuanmei.config.ViewHolder;
import com.hanhanxiaochong.zhongxiangchuanmei.util.ResourcesUtils;
import com.hanhanxiaochong.zhongxiangchuanmei.util.glide.GlideImgManager;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.RetrofitSource;

import java.util.List;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/4/30.
 * Desc   :
 */

public class OnlyVipAdapter extends CommonAdapter<VipProjectItem> {

    public OnlyVipAdapter(Context context, int layoutId, List<VipProjectItem> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, VipProjectItem bean, int position) {
        ImageView ivPic = holder.getView(R.id.iv_good_pic);
        GlideImgManager.glideLoader(mContext, RetrofitSource.image_url + bean.getPic().split(",")[0], R.mipmap.img_error, R.mipmap.img_error, ivPic);
        holder.setText(R.id.tv_good_name, bean.getName());
        ImageView selfSupport = holder.getView(R.id.iv_self_support);
        selfSupport.setVisibility(bean.getSelf_support().equals("y") ? View.VISIBLE : View.GONE);
        holder.setText(R.id.tv_normal_price, String.format(ResourcesUtils.getString(R.string.normal_good_price), bean.getPrice()));
        holder.setText(R.id.tv_project_fit, String.format(ResourcesUtils.getString(R.string.project_fit), bean.getSymptom_lists()));
        holder.setText(R.id.tv_project_time, String.format(ResourcesUtils.getString(R.string.project_time), bean.getWhen_long()));
    }
}
